import { useEffect, useRef, useState } from 'react';
import s from './index.module.scss';
import PullDown from './components/PullDown';

const PullRefreshPage = () => {

  const prodRef = useRef(null);

  const [data, setData] = useState({});

  const getProdInfo = () => {
    console.log('更新啦')
    const prodInfo = {
      title: '测试',
      price: 59.9,
      content: '超级好吃的东西哈哈哈哈！',
    }

    setData(prodInfo);
  }

  return (
    <PullDown refresh={getProdInfo} focusRef={prodRef} pullHeight={70} loadingPic={'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F0196fa582abab6a84a0d304f899eaf.gif&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1642933558&t=faa8a93293c8be1c79572a3800432585'}>
      <div className={s.container}>
        <div className={s.header}>这是标题</div>
        <div ref={prodRef} className={s.main}>{JSON.stringify(data)}</div>
      </div>
    </PullDown>
  )
}

export default PullRefreshPage;